package com.example.bookmarks.xmlmapper;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;

import java.util.List;

@JacksonXmlRootElement(localName = "H3")
public class BookmarkH3 {
    @JacksonXmlProperty(isAttribute = true, localName = "ADD_DATE")
    private String addDate;

    @JacksonXmlProperty(isAttribute = true, localName = "LAST_MODIFIED")
    private String lastModified;

    @JacksonXmlProperty(isAttribute = true, localName = "PERSONAL_TOOLBAR_FOLDER")
    private String personalToolbarFolder;

    @JacksonXmlProperty(localName = "H3")
    @JacksonXmlElementWrapper(useWrapping = false)
    private List<BookmarkH3> subBookmarkH3s;

    @JacksonXmlProperty(localName = "A")
    @JacksonXmlElementWrapper(useWrapping = false)
    private List<BookmarkLink> links;

    // Plain text content of the bookmark folder
    @JacksonXmlProperty(isAttribute = false)
    private String content;

    // Getters and setters
    public String getAddDate() {
        return addDate;
    }

    public void setAddDate(String addDate) {
        this.addDate = addDate;
    }

    public String getLastModified() {
        return lastModified;
    }

    public void setLastModified(String lastModified) {
        this.lastModified = lastModified;
    }

    public String getPersonalToolbarFolder() {
        return personalToolbarFolder;
    }

    public void setPersonalToolbarFolder(String personalToolbarFolder) {
        this.personalToolbarFolder = personalToolbarFolder;
    }

    public List<BookmarkH3> getSubBookmarks() {
        return subBookmarkH3s;
    }

    public void setSubBookmarks(List<BookmarkH3> subBookmarkH3s) {
        this.subBookmarkH3s = subBookmarkH3s;
    }

    public List<BookmarkLink> getLinks() {
        return links;
    }

    public void setLinks(List<BookmarkLink> links) {
        this.links = links;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Override
    public String toString() {
        return "Bookmark{" +
                "content='" + content + '\'' +
                ", addDate='" + addDate + '\'' +
                ", lastModified='" + lastModified + '\'' +
                ", personalToolbarFolder='" + personalToolbarFolder + '\'' +
                ", subBookmarks=" + (subBookmarkH3s != null ? subBookmarkH3s.size() : 0) +
                ", links=" + (links != null ? links.size() : 0) +
                '}';
    }
}